<template>
  <div>
    <!-- 面包屑 -->
    <bread :bread="$route.meta.bread" />
    <!-- 图表区域 -->
    <div id="box" class="box"></div>
  </div>
</template>

<script>
import bread from "../common/bread.vue";
export default {
  components: { bread },
  data() {
    return {};
  },
  created() {},
  mounted() {
    // 调用数据参数
    this.getEcharts();
  },
  methods: {
    // 基于准备好的dom，初始化echarts实例
    getEcharts() {
      let myEchart = this.$echarts.init(document.getElementById("box"));
      // 绘制图表
      let option = {
        title: {
          text: "堆叠区域图",
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#6a7985",
            },
          },
        },
        legend: {
          data: ["华东", "华南", "华北", "西部", "其他"],
        },
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            data: [
              "2017-12-27",
              "2017-12-28",
              "2017-12-29",
              "2017-12-30",
              "2017-12-31",
              "2018-1-1",
            ],
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
        series: [
          {
            name: "华东",
            type: "line",
            stack: "总量",
            areaStyle: {},
            data: [2999, 3111, 4100, 3565, 3528, 6000],
          },
          {
            name: "华南",
            type: "line",
            stack: "总量",
            areaStyle: {},
            data: [5090, 2500, 3400, 6000, 6400, 7800],
          },
          {
            name: "华北",
            type: "line",
            stack: "总量",
            areaStyle: {},
            data: [6888, 4000, 8010, 12321, 13928, 12984],
          },
          {
            name: "西部",
            type: "line",
            stack: "总量",
            areaStyle: {},
            data: [9991, 4130, 7777, 12903, 13098, 14028],
          },
          {
            name: "其他",
            type: "line",
            stack: "总量",
            label: {
              normal: {
                show: true,
                position: "top",
              },
            },
            areaStyle: {},
            data: [15212, 5800, 10241, 14821, 15982, 14091],
          },
        ],
      };
      myEchart.setOption(option);
    },
  },
};
</script>

<style scoped>
.box {
  width: 600px;
  height: 500px;
}
</style>
